package com.resou.reader.api;

import android.annotation.SuppressLint;

import com.resou.reader.api.entry.CommentBean;
import com.resou.reader.api.entry.CommonData;
import com.resou.reader.api.entry.Result;
import com.resou.reader.api.entry.TestBean;
import com.resou.reader.api.entry.TypeBean;
import com.resou.reader.api.entry.VIPConfigBean;
import com.resou.reader.api.service.BookService;
import com.resou.reader.api.service.PayService;
import com.resou.reader.api.service.SearchService;
import com.resou.reader.api.service.UserService;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * Created by Garrett on 2018/8/30.
 * contact me krouky@outlook.com
 */
public class InterfaceTest {

    public static void main(String[] args) {
        BookService service = (BookService) ApiImp.getInstance().getService(BookService.class);
//        searchTest();
//        userText();
//        testComment();
//        testType(service);
//        testnickname();
        test1();
    }

    private static void testnickname() {
        TestBean bena = new TestBean();
        String token = "A9A167B195DEE9D6003E2FE6F22148E4";
        String nickname = "111";
        bena.setToken("A9A167B195DEE9D6003E2FE6F22148E4");
        bena.setNickname("1");
    }

    @SuppressLint("CheckResult")
    private static void testType(BookService service) {

    }

    private static void test1() {
        String token = "A9A167B195DEE9D6003E2FE6F22148E4";
        String nickName = "1111";

        ApiImp.getInstance().getService(UserService.class).updateNickname(token, nickName);
    }

//    private static void testComment() {
//        BookService service = (BookService) ApiImp.getInstance().getService(BookService.class);
//        service.reviewComment( "1942", 0, 10).subscribe(new Observer<Result<List<CommentBean>>>() {
//            @Override
//            public void onSubscribe(Disposable d) {
//
//            }
//
//            @Override
//            public void onNext(Result<List<CommentBean>> listResult) {
//                System.out.println(listResult.getMsg());
//                System.out.println(listResult.getData());
//            }
//
//            @Override
//            public void onError(Throwable e) {
//
//            }
//
//            @Override
//            public void onComplete() {
//
//            }
//        });
//    }

    private static void userText() {
        PayService service = ApiImp.getInstance().getService(PayService.class);
        service.vipPriceConfig().subscribe(new Observer<Result<List<VIPConfigBean>>>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Result<List<VIPConfigBean>> listResult) {
                System.out.println("onNext -- > " + listResult.getMsg());
                System.out.println("onNext -- > " + listResult.getData().size());
            }

            @Override
            public void onError(Throwable e) {
                System.out.println("onError -- > " + e.getMessage());
            }

            @Override
            public void onComplete() {
                System.out.println("onComplete ..");
            }
        });
    }

    private static void searchTest() {
        SearchService service = (SearchService) ApiImp.getInstance().getService(SearchService.class);
        service.searchPush().subscribe(new Observer<Result<CommonData<List<String>>>>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(Result<CommonData<List<String>>> listResult) {
                System.out.println("onNext -- > " + listResult.getMsg());
                System.out.println("onNext -- > " + listResult.getData().getData().size());
            }

            @Override
            public void onError(Throwable e) {
                System.out.println("onError -- > " + e.getMessage());
            }

            @Override
            public void onComplete() {
                System.out.println("onComplete ..");
            }
        });
    }

}
